<%--
  Created by IntelliJ IDEA.
  User: fyf
  Date: 2018/11/12
  Time: 9:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  session.getAttribute("branchid");
  session.getAttribute("branchName");
%>
<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  <meta charset="utf-8"/>

  <title>添加课程信息</title>

  <meta name="description" content="User login page"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

  <!-- bootstrap & fontawesome -->
  <link rel="stylesheet" href="/assets/css/bootstrap.css"/>
  <link rel="stylesheet" href="/assets/css/font-awesome.css"/>

  <!-- text fonts -->
  <link rel="stylesheet" href="/assets/css/ace-fonts.css"/>

  <!-- ace styles -->
  <link rel="stylesheet" href="/assets/css/ace.css"/>



  <jsp:include page="/common/basecss.jsp" flush="true"/>
  <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>
  <script src="${pageContext.request.contextPath}/assets/js/layer-v3.1.0/layer/layer.js"></script>
</head>
<body>


<form id="validation-form" class="form-inline" method="post">

  <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">课程信息</h5>
  <div class="row">

    <div class="form-group">
      <label class="col-sm-3 control-label">课程id</label>
      <div class="col-sm-6">
        <input type="text" name="id" readonly="readonly" class="form-control input-sm"
               placeholder="课程id由数据库后台生成" />
      </div>
    </div>

  </div>

  <%--分公司id--%>
  <input type="hidden" name="branchid" id="branchid"   value="${branchid}">


  <div class="row">

    <div class="form-group">
      <label class="col-sm-3 control-label">课程名称</label>
      <div class="col-sm-6">
        <input type="text" name="coursename" id="coursename" class="form-control input-sm"
               placeholder="请填写课程名称" required />
      </div>
    </div>

  </div>

  <p style="color:red" id="message1" hidden>${message }</p>

  <div class="row">
    <div class="text-center">
      <input  type="button" id="submitButton" class="btn btn-success" value="添加"/>

    </div>
  </div>
</form>


<script>

    $(function () {

       /* $("#validation-form").validate({
            rules: {
                coursename: {
                    required: true
                }
            },
            messages: {
                coursename:"请填写教师名称"
            }

        });*/



        $("#submitButton").click(function () {

            var coursename =  $('#coursename').val();
            var branchId= $('#branchid').val();
            $.ajax({
                type:'post',
                url:'addCourse.go',
                data:{"coursename":coursename,"branchId":branchId},
                dataType:'json',
                success:function (resData) {
                    if (resData!= null&&resData.coursename!=null&&resData.coursename!=""){
                        layer.msg('课程添加成功',{icon: 1});
                        /*ajax提交，成功之后父级页面刷新*/
                        setTimeout(function () {
                            parent.location.reload();
                        },1000);

                    }else if(resData.coursename=null||resData.coursename==""){
                        layer.msg('请填写课程名称',{icon: 4})
                    }else {
                        layer.msg('课程更新失败',{icon: 2});
                    }
                },
                error:function () {

                }
            });
        });

       /* //信息提示：
        var message = document.getElementById("message1").innerText;
        if(message){
            layer.alert(message, {
                icon:4,
                title: "提示"
            });
        }else{
            hidden(message)
        }*/



    });


</script>




<jsp:include page="/common/basejs.jsp" flush="true"/>
</body>
</html>
